package com.yiyahui.project.erp.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import com.yiyahui.framework.aspectj.lang.annotation.Log;
import com.yiyahui.framework.aspectj.lang.enums.BusinessType;
import com.yiyahui.project.erp.domain.YiyaDiagnose;
import com.yiyahui.project.erp.service.IYiyaDiagnoseService;
import com.yiyahui.framework.web.controller.BaseController;
import com.yiyahui.framework.web.domain.AjaxResult;
import com.yiyahui.common.utils.poi.ExcelUtil;
import com.yiyahui.framework.web.page.TableDataInfo;

/**
 * 看诊Controller
 * 
 * @author yiyahui
 * @date 2020-05-16
 */
@Api("看诊")
@RestController
@RequestMapping("/erp/diagnose")
public class YiyaDiagnoseController extends BaseController
{
    @Autowired
    private IYiyaDiagnoseService yiyaDiagnoseService;
 
    /**
     * 查询看诊列表
     */
    @ApiOperation("查询看诊列表")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:list')")
    @GetMapping("/list")
    public TableDataInfo list(YiyaDiagnose yiyaDiagnose)
    {
        startPage();
        List<YiyaDiagnose> list = yiyaDiagnoseService.selectYiyaDiagnoseList(yiyaDiagnose);
        return getDataTable(list);
    }

    /**
     * 导出看诊列表
     */
    @ApiOperation("导出看诊列表")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:export')")
    @Log(title = "看诊", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YiyaDiagnose yiyaDiagnose)
    {
        List<YiyaDiagnose> list = yiyaDiagnoseService.selectYiyaDiagnoseList(yiyaDiagnose);
        ExcelUtil<YiyaDiagnose> util = new ExcelUtil<YiyaDiagnose>(YiyaDiagnose.class);
        return util.exportExcel(list, "diagnose");
    }

    /**
     * 获取看诊详细信息
     */
    @ApiOperation("获取看诊详细信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, dataType = "Long", paramType = "path")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yiyaDiagnoseService.selectYiyaDiagnoseById(id));
    }

    /**
     * 新增看诊
     */
    @ApiOperation("新增看诊")
    @ApiImplicitParam(name = "yiyaDiagnose", value = "${tableComment}", dataType = "YiyaDiagnose")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:add')")
    @Log(title = "看诊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YiyaDiagnose yiyaDiagnose)
    {
        return toAjax(yiyaDiagnoseService.insertYiyaDiagnose(yiyaDiagnose));
    }

    /**
     * 修改看诊
     */
    @ApiOperation("修改看诊")
    @ApiImplicitParam(name = "yiyaDiagnose", value = "${tableComment}", dataType = "YiyaDiagnose")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:edit')")
    @Log(title = "看诊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YiyaDiagnose yiyaDiagnose)
    {
        return toAjax(yiyaDiagnoseService.updateYiyaDiagnose(yiyaDiagnose));
    }

    /**
     * 删除看诊
     */
    @ApiOperation("删除看诊")
    @ApiImplicitParam(name = "ids", value = "主键id数组", required = true, dataType = "Long[]", paramType = "path")
    @PreAuthorize("@ss.hasPermi('erp:diagnose:remove')")
    @Log(title = "看诊", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yiyaDiagnoseService.deleteYiyaDiagnoseByIds(ids));
    }
}
